package com.cuij.servicelmpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cuij.dao.orderCustDao;
import com.cuij.entity.Result;
import com.cuij.entity.orderCust;
import com.cuij.service.orderCustService;

@Service
public class orderCustServicelmpl implements orderCustService {

    @Resource
    private orderCustDao ordercustdao;

    public Result findCustInfoByUseid(String use_id) {
        Result result = new Result();
        Map cust = ordercustdao.findcustinfobyuseid(use_id);
        Map custInfos = new HashMap();
        List custList = new ArrayList();
        for (int i = 1; i <= 5; i++) {
            if (null != cust.get("CUST_ADDRESS" + i) && "" != cust.get("CUST_ADDRESS" + i).toString()) {
                custList.add(cust.get("CUST_ADDRESS" + i));
            }
        }
        String cust_money = cust.get("CUST_MONEY").toString();
        custInfos.put("custList", custList);
        custInfos.put("cust_money", cust_money);
        result.setStatus(0);
        result.setData(custInfos);
        return result;
    }

    // 修改保存地址
    public Result saveAddress(String use_id, String cust_address1, String cust_address2, String cust_address3,
            String cust_address4, String cust_address5) {
        Result result = new Result();
        orderCust ordercust = new orderCust();
        ordercust.setUse_id(use_id);
        ordercust.setCust_address1(cust_address1);
        ordercust.setCust_address2(cust_address2);
        ordercust.setCust_address3(cust_address3);
        ordercust.setCust_address4(cust_address4);
        ordercust.setCust_address5(cust_address5);
        ordercustdao.saveaddress(ordercust);
        result.setStatus(0);
        return result;
    }

}
